package com.own.business.exam.entity.dto;


import com.own.business.exam.entity.bo.ExamRuleQuestionBo;
import com.own.component.common.base.entity.BaseDto;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.math.BigDecimal;

/**
 * ExamRuleQuestionDto
 *
 * @author chenxueli
 * @date 2021/05/18 14:43:47
 */
@Schema(title = "考试规则题目表" + ConstantBeanSuffix.DTO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class ExamRuleQuestionDto extends BaseDto<ExamRuleQuestionBo> {

    @Schema(title = "规则id")
    private Long ruleId;

    @Schema(title = "题目id")
    private Long questionId;

    @Schema(title = "题目分数")
    private BigDecimal score;

    @Schema(title = "答对一部分的分数")
    private BigDecimal someRightScore;

    /**
     * 转业务层对象
     *
     * @param entity 原业务层对象
     * @return 业务层对象
     */
    @Override
    public ExamRuleQuestionBo toBo(ExamRuleQuestionBo entity) {
        if (entity == null) {
            entity = new ExamRuleQuestionBo();
        }
        entity.setRuleId(ruleId);
        entity.setQuestionId(questionId);
        entity.setScore(score);
        entity.setSomeRightScore(someRightScore);
        return super.toBo(entity);
    }

}
